<?php
// +----------------------------------------------------------------------
// | [KyPHP System] Copyright (c) 2020 http://www.kuryun.com/
// +----------------------------------------------------------------------
// | [KyPHP] 并不是自由软件,你可免费使用,未经许可不能去掉KyPHP相关版权
// +----------------------------------------------------------------------
// | License  https://gitee.com/fudaoji/KyPHP/blob/master/LICENSE
// +----------------------------------------------------------------------
/**
 * Created by PhpStorm.
 * Script Name: Base.php
 * Create: 2020/8/1 10:00
 * Description: 官网控制器基类
 * Author: fudaoji<fdj@kuryun.cn>
 */

namespace app\home\controller;

use app\common\controller\BaseCtl;

class Base extends BaseCtl
{
    protected $adminInfo = [];
    public function initialize()
    {
        parent::initialize(); // TODO: Change the autogenerated stub
        $this->setAdminInfo();
        $this->getFriendLink();
    }

    /**
     * 设置账号信息
     * @return array
     * Author: fudaoji<fdj@kuryun.cn>
     */
    protected function setAdminInfo()
    {
        $aid = (int)session("adminId");
        $this->adminInfo = model("admin")->getOne($aid);
        $this->assign['user'] = $this->adminInfo;
        return $this->adminInfo;
    }

    /**
     * 友链
     * @return mixed
     * Author: fudaoji<fdj@kuryun.cn>
     */
    protected function getFriendLink(){
        $list = model('friendLink')->getAll([
            'where' => ['status' => 1],
            'order' => ['sort' => 'asc']
        ]);
        $this->assign['friend_link'] = $list;
        return $list;
    }
}